//
//  ZYForgetPassword.m
//  YiLin
//
//  Created by Zyark on 2018/5/29.
//  Copyright © 2018年 Zyark. All rights reserved.
//

#import "ZYForgetPasswordVC.h"
#import "ZYPhoneRecoverVC.h"
#import "ZYProblemRecoverOneVC.h"
#import "ZYImageUtils.h"

@interface ZYForgetPasswordVC ()
@property(nonatomic,strong) UIButton *phoneRecoverBtn;
@property(nonatomic,strong) UIButton *emailRecoverBtn;
@property(nonatomic,strong) UIButton *problemRecoverBtn;
@end

@implementation ZYForgetPasswordVC

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setup];
}

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    self.title = [[ZYChangeLanguage sharedZYChangeLanguage] getStringByKey:LC_FORGET_PASSWORD_CONTROLLER_TITLE];
//    self.tabBarController.tabBar.hidden = YES;
}

-(void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
//    self.tabBarController.tabBar.hidden = NO;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

-(void)setup{
    ZYChangeLanguage *language = [ZYChangeLanguage sharedZYChangeLanguage];
    _phoneRecoverBtn = [self setupButtonWithTitle:[language getStringByKey:LC_FORGET_PHONE_RECOVER] action:@selector(doPhoneRecover:)];
    _emailRecoverBtn = [self setupButtonWithTitle:[language getStringByKey:LC_FORGET_EMAIL_RECOVER] action:@selector(doEmailRecover:)];
    _problemRecoverBtn = [self setupButtonWithTitle:[language getStringByKey:LC_FORGET_PROBLEM_RECOVER] action:@selector(doProblemRecover:)];
    _phoneRecoverBtn.top = self.view.top + ZYSCREEN_H * 0.2;
    _phoneRecoverBtn.centerX = self.view.centerX;
    
    
    _emailRecoverBtn.top = _phoneRecoverBtn.bottom + ZYSCREEN_H * 0.05;
    _emailRecoverBtn.centerX = self.view.centerX;
    
    _problemRecoverBtn.top = _emailRecoverBtn.bottom + ZYSCREEN_H * 0.05;
    _problemRecoverBtn.centerX = self.view.centerX;
}


/**
 初始化按钮
 @param title 标题
 @param action 点击事件
 */
-(UIButton *)setupButtonWithTitle:(NSString *)title action:(SEL)action{
    CGFloat width = ZYSCREEN_W * 0.73;
    CGFloat height = ZYSCREEN_H * 0.09;
    UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, width, height)];
    [button setTitle:title forState:UIControlStateNormal];
    [button setTitleColor:kMainColor forState:UIControlStateNormal];
    [button setBackgroundImage:[ZYImageUtils imageWithColor:[UIColor whiteColor] rect:button.bounds] forState:UIControlStateNormal];
    [button setBackgroundImage:[ZYImageUtils imageWithColor:kMainColor rect:button.bounds] forState:UIControlStateHighlighted];
    [button setTitleColor:[UIColor whiteColor] forState:UIControlStateHighlighted];
    button.layer.borderColor = kMainColor.CGColor;
    button.layer.borderWidth = 1;
    button.layer.cornerRadius = 5;
    button.layer.masksToBounds = YES;
    [button addTarget:self action:action forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button];
    return button;
}

#pragma mark - Event
-(void)doPhoneRecover:(id)button{
    ZYPhoneRecoverVC *vc = [[ZYPhoneRecoverVC alloc] init];
    vc.type = ZYRecoverPasswordTypePhone;
    [self.navigationController pushViewController:vc animated:YES];
}

-(void)doEmailRecover:(id)button{
    ZYPhoneRecoverVC *vc = [[ZYPhoneRecoverVC alloc] init];
    vc.type = ZYRecoverPasswordTypeEmail;
    [self.navigationController pushViewController:vc animated:YES];
}

-(void)doProblemRecover:(id)button{
    ZYProblemRecoverOneVC * vc= [[ZYProblemRecoverOneVC alloc] init];
    [self.navigationController pushViewController:vc animated:YES];
}

@end
